Read file before creating directory #644
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After spending some time debugging where babel-loader compile time goes I found out that it tries to run mkdirp to create the cache directory for every possible file that's passed to babel-loader. This change makes sure that it only tries to create the directory if something has to be written to it.
This is still not ideal as it tries to create the directory for every file that's not there (this can take from 0 to 50ms per file from benchmarks I ran on a relatively large app (220 webpack entrypoints and around 1000 components)).
The most performant solution is keeping track of directories that were already created using a
new Set()
, but that seems to fail the tests as after every test the directory is removed and the internal cache remains.